<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/tags.jsp"%>
<aos:html>
<aos:head title="客户消息管理信息列表">
	<aos:include lib="ext" />
	<aos:base href="console/customeruser" />
</aos:head>
<aos:body>
</aos:body>
<aos:onready>
	<aos:viewport layout="border">
		<aos:formpanel id="qform" labelWidth="70" region="north"
			header="false" padding="5 0 0 0" border="false">
			<aos:textfield fieldLabel="公司名称" name="customer_company" />
			<aos:textfield fieldLabel="联系人" name="ustomer_header_name" />
			<aos:textfield fieldLabel="联系方式" name="customer_mobile" />
			<aos:button width="80" text="查 询" margin="0 0 0 15px"
				icon="search.png" onclick="query"></aos:button>
			<aos:button width="80" text="重 置" margin="0 0 0 15px"
				icon="refresh1.png" onclick="AOS.reset(qform)"></aos:button>
		</aos:formpanel>
		<aos:gridpanel id="grid" url="list" onrender="query"
			 region="center">
			<aos:docked>
			</aos:docked>
			<aos:selmodel type="checkbox" mode="multi" />
			<aos:column type="rowno" header="序号" width="40" />
			<aos:column header="id" dataIndex="id" width="40" />

			<aos:column header="公司名称" dataIndex="customer_company" width="60" />
			<aos:column header="联系人" dataIndex="customer_header_name" width="100" />
			<aos:column header="联系方式" dataIndex="customer_mobile" width="60" />
			<aos:column header="地址 " dataIndex="customer_address" width="130" />
			<aos:column header="消费总金额 " dataIndex="total_spend" width="130" />
			<aos:column header="消费次数 " dataIndex="consume_times" width="130" />
			<aos:column header="所属代理商ID " dataIndex="agentid" hidden="true" width="130" />
			<aos:column header="所属代理商 " dataIndex="agent_name" width="130" />
			<aos:column header="创建时间" dataIndex="createTime" width="130" />
		</aos:gridpanel>

		<aos:window id="add_w" title="新增客户信息" maxHeight="-10"
			autoScroll="true">
			<aos:formpanel id="add_f" width="420" layout="anchor" labelWidth="80">
				<aos:textfield name="customer_company" fieldLabel="客户公司名称"
					allowBlank="false" />
				<aos:textfield name="customer_header_name" fieldLabel="联系人"
					allowBlank="false" />
				<aos:textfield name="customer_mobile" fieldLabel="联系方式" allowBlank="false" />
				<aos:textfield name="customer_address" fieldLabel="地址 "
					allowBlank="false" />
				<aos:combobox name="agentid" fieldLabel="所属公司" url="../findAgents"
					emptyText="－－请选择－－" allowBlank="false" />
			</aos:formpanel>
			<aos:docked dock="bottom" ui="footer">
				<aos:dockeditem xtype="tbfill" />
				<aos:dockeditem onclick="add" text="保存" icon="ok.png" />
				<aos:dockeditem onclick="#add_w.hide();" text="关闭" icon="close.png" />
			</aos:docked>
		</aos:window>
		<aos:window id="update_w" title="修改项目信息" maxHeight="-10"
			autoScroll="true">
			<aos:formpanel id="update_f" width="420" layout="anchor"
				labelWidth="80">
				<aos:textfield name="id" fieldLabel="ID" allowBlank="false"
					readOnly="true" />
				<aos:textfield name="customer_company" fieldLabel="客户公司名称"
					allowBlank="false" />
				<aos:textfield name="customer_header_name" fieldLabel="联系人"
					allowBlank="false" />
				<aos:textfield name="customer_mobile" fieldLabel="联系方式" allowBlank="false" />
				<aos:textfield name="customer_address" fieldLabel="地址 "
					allowBlank="false" />
			<aos:combobox id="_company_1" name="agentid" fieldLabel="所属代理商"
				url="../findAgents" queryMode="local" emptyText="－－请选择－－"
				allowBlank="false" />
			</aos:formpanel>
			<aos:docked dock="bottom" ui="footer">
				<aos:dockeditem xtype="tbfill" />
				<aos:dockeditem onclick="update" text="修改" icon="ok.png" />
				<aos:dockeditem onclick="#update_w.hide();" text="关闭"
					icon="close.png" />
			</aos:docked>
		</aos:window>
	</aos:viewport>

	<script type="text/javascript">
	
	window.onload = function() {
		_company_1_store.load();
	}
    
    function state_ren(v){
		if(v == 0){
			return '正常'
		}else if(v == 1){
			return '关闭'
		}else{
			return v
		}
	}
    
   	 
    function query(){
        grid_store.getProxy().extraParams = qform.getValues();
        grid_store.getProxy().getMethod = function(){ return 'POST'; }
        grid_store.load();
     }

	function show_add(){
		AOS.reset(add_f);
        add_w.show();
	}
	
	function add(){
		AOS.ajax({
            forms : add_f,
            url : 'add',
            ok : function(data) {
                	if(data.success){
                		 add_w.hide();
                     grid_store.reload();
                	}
                AOS.tip(data.appmsg);
            }
        }); 
	}
    function show_update(){
        AOS.reset(update_f);
        grid_store.reload();           
        var record = AOS.selectone(grid);
        grid.getSelectionModel().clearSelections();
        if(record){
            update_w.show();
            update_f.loadRecord(record);
        }
    }        
    
    function update(){
           AOS.ajax({
            forms : update_f,
            url : 'update',
            ok : function(data) {
                	if(data.success){
                		update_w.hide();
                    grid_store.reload();
                    grid.getSelectionModel().clearSelections()
                	}
                	AOS.tip(data.appmsg);
            }
        }); 
    }
    </script>
</aos:onready>
</aos:html>